using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting.Lifetime;

namespace Midas.Core
{
	public class ManagerSponsor : MarshalByRefObject, ISponsor
	{
		public static void RegisterSponsor(MarshalByRefObject obj, ISponsor sponsor)
		{
			ILease lease = (ILease)obj.GetLifetimeService();
			lease.Register(sponsor);
		}
		
		public static void UnregisterSponsor(MarshalByRefObject obj, ISponsor sponsor)
		{
			ILease lease = (ILease)obj.GetLifetimeService();
			lease.Unregister(sponsor);
		}

		private bool renew=true;

		public bool Renew
		{
			get { return renew; }
			set { renew = value; }
		}
		#region ISponsor Members

		public TimeSpan Renewal(ILease lease)
		{
			return renew?lease.InitialLeaseTime:TimeSpan.Zero;
		}

		#endregion
	}
}
